#!/usr/bin/env sh
set -e

if [ $MYSQL_ADDR ] && [ $MYSQL_DB ] && [ $MYSQL_USER ] && [ $MYSQL_PASSWORD ]; then
  echo "MYSQL_ADDR: ${MYSQL_ADDR}"
  echo "MYSQL_USER: ${MYSQL_USER}"
  export MYSQL_DSN="${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(${MYSQL_ADDR})/${MYSQL_DB}?parseTime=true"
  echo $MYSQL_DSN
fi

echo "command: $@"
exec "$@"
